package com.wicket.okrapp.biz.service.impl;

import com.wicket.okrapp.biz.service.dto.req.*;
import com.wicket.okrapp.biz.service.dto.res.*;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import com.wicket.okrapp.common.util.RedisUtil;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

import com.wicket.okrapp.common.exception.Assert;
import com.wicket.okrapp.biz.service.nb.NbCalculationRules;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class CalculationRulesServiceImpl implements com.wicket.okrapp.biz.service.CalculationRulesService {
    @Resource
    private RedisUtil redisUtil;
//@Resource
 //private MCustomFieldsService mCustomFieldsService;
@Resource
  private NbCalculationRules nbCalculationRules;
/**
   * D3计算时间相减得偏差服务(公共)[3366]
   * gen by moon at 10/17/2023, 4:56:49 PM
   */
  @Trace(operationName = "D3计算时间相减得偏差服务(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public CalculateCaluDateDiffServiceComRespDto calculateCaluDateDiffServiceCom(CalculateCaluDateDiffServiceComReqDto reqDto){
    
      
      CalculateCaluDateDiffRespDto caluTimeDiffRes_1 =null;
//步骤0: M3-计算时间相减得偏差 - calculateCaluDateDiff
     //ModelCode: caluTimeDiff
        CalculateCaluDateDiffRespDto caluTimeDiffRes = null;
    CalculateCaluDateDiffReqDto caluTimeDiffReq=new CalculateCaluDateDiffReqDto();
  if(reqDto!=null){
      caluTimeDiffReq.setCaluStartTime(reqDto.getCaluStartTime());//SimpleFieldAssign//sourceId:133506_1
caluTimeDiffReq.setCaluEndTime(reqDto.getCaluEndTime());//SimpleFieldAssign//sourceId:133507_1
    }
  
    /*M3-计算时间相减得偏差[2934]  入参计算开始时间，计算结束时间。截取计算结束时间的YYYY-MM-DD减去截取计算开始时间YYYY-MM-DD，即计算“计算结束时间”，“计算开始时间”两个时间之前相差的天数，输出正负数值或0 */
    Assert.isNull(caluTimeDiffReq.getCaluStartTime(),"D3计算时间相减得偏差服务(公共)-M3-计算时间相减得偏差-参照时间不能为空",false);
Assert.isNull(caluTimeDiffReq.getCaluEndTime(),"D3计算时间相减得偏差服务(公共)-M3-计算时间相减得偏差-被减时间不能为空",false);
      caluTimeDiffRes = nbCalculationRules.calculateCaluDateDiff(caluTimeDiffReq);
      
      
      caluTimeDiffRes_1 = caluTimeDiffRes;
    
CalculateCaluDateDiffServiceComRespDto retData = new CalculateCaluDateDiffServiceComRespDto();
  if(caluTimeDiffRes_1!=null){
      retData.setTimeDiffDays(caluTimeDiffRes_1.getTimeDiffDays());//SimpleFieldAssign//sourceId:133509_1
retData.setTimeDiffHours(caluTimeDiffRes_1.getTimeDiffHours());//SimpleFieldAssign//sourceId:135716_1
    }
  

  
  
return retData;
  }
    
    //
}
